﻿using System;
using Assist;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using YJKSparseDistance.Properties;
using YJKRevitKernel.ShortPathSuite;
using YJKInspectModelFunc.ModelLayer;

namespace YJKSparseDistance.ModelLayer
{
	public class EndPointPacker : BaseEndPointPacker
	{
		public XYZ AppendPoint
		{
			get
			{
				return this.m_AppendPoint;
			}
		}

		public bool IfFinalEnd
		{
			get
			{
				return this.m_bIfFinalEnd;
			}
			set
			{
				this.m_bIfFinalEnd = value;
			}
		}

		public Room ThisRoom
		{
			get
			{
				return this.m_ThisRoom;
			}
		}

		public BaseElementPacker UseElementPacker
		{
			get
			{
				return this.m_useElement;
			}
		}

		public bool IfSparay
		{
			get
			{
				return this.m_bIfSparay;
			}
			private set
			{
				this.m_bIfSparay = value;
			}
		}

		public EndPointPacker(BaseElementPacker thisElementPacker, Room useRoom, XYZ useEndPoint, XYZ appendEndPoint = null, bool ifStartPoint = true, bool ifSparay = false, bool ifToOpenStairRoom = false)
		{
			this.m_useElement = thisElementPacker;
			this.m_ThisRoom = useRoom;
			this.m_UseEndPoint = useEndPoint;
			this.m_AppendPoint = appendEndPoint;
			this.m_bIfToOpenStairRoom = ifToOpenStairRoom;
			this.m_bIfStartPoint = ifStartPoint;
			this.IfSparay = ifSparay;
		}

		public virtual double GetFactoryAndSubValue(out double subValue)
		{
			double result = double.Parse(Resources.Str_One);
			subValue = double.Parse(Resources.Str_Zero);
			if (this.IfSparay)
			{
				result = double.Parse(Resources.Str_OnePointTwoFive);
				if (this.m_bIfToOpenStairRoom)
				{
					if (this.IfFinalEnd)
					{
						subValue = double.Parse(Resources.Str_TwoMeter);
					}
					else
					{
						subValue = double.Parse(Resources.Str_FiveMeter);
					}
				}
			}
			else
			{
				result = double.Parse(Resources.Str_One);
				if (this.m_bIfToOpenStairRoom)
				{
					if (this.IfFinalEnd)
					{
						subValue = double.Parse(Resources.Str_TwoMeter);
					}
					else
					{
						subValue = double.Parse(Resources.Str_FiveMeter);
					}
				}
			}
			subValue *= double.Parse(Resources.Str_OneK);
			subValue = AssistFunc.mmToFeet(subValue);
			return result;
		}

		public override string ToString()
		{
			return string.Empty + this.m_useElement.ElementId.ToString() + "," + this.m_useElement.LinkInstanceId.ToString();
		}

		public override bool Equals(object obj)
		{
			if (!(obj is EndPointPacker))
			{
				return false;
			}
			EndPointPacker endPointPacker = obj as EndPointPacker;
			return endPointPacker != null && ((XYZCompare.GetCompare().Equals(base.UseEndPoint, endPointPacker.UseEndPoint) && XYZCompare.GetCompare().Equals(this.AppendPoint, endPointPacker.AppendPoint) && this.m_bIfToOpenStairRoom == endPointPacker.m_bIfToOpenStairRoom && this.m_bIfStartPoint == endPointPacker.m_bIfStartPoint && this.IfSparay == endPointPacker.IfSparay && this.m_ThisRoom.Id.IntegerValue == endPointPacker.m_ThisRoom.Id.IntegerValue) || base.Equals(obj));
		}

		public override int GetHashCode()
		{
			return base.GetHashCode();
		}

		private XYZ m_AppendPoint;

		private bool m_bIfToOpenStairRoom;

		private bool m_bIfFinalEnd;

		private bool m_bIfSparay;

		private Room m_ThisRoom;

		private BaseElementPacker m_useElement;
	}
}
